package cn.wolfcode.luowowo.search.template;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Setter
@Getter
@ToString
@Document(indexName = ScenicCommentTemplate.INDEX_TYPE_NAME, type = ScenicCommentTemplate.INDEX_TYPE_NAME)
public class ScenicCommentTemplate implements Serializable {
    public static final String INDEX_TYPE_NAME = "luowowo_sceniccomment";

    @Id
    private long id;//ES id

    private Long scenicId;//景点id

    private Long userId;//用户id

    @Field(type = FieldType.Keyword)
    private String username;//用户名字

    private Integer level;//用户等级

    @Field(type = FieldType.Keyword)
    private String headUrl;//用户头像

    @Field(pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis", type = FieldType.Date, format = DateFormat.custom)
    private Date createTime;//点评时间

    @Field(index = true, analyzer = "ik_max_word", store = true, searchAnalyzer = "ik_max_word", type = FieldType.Text)
    private String comment;//点评内容

    private Integer thumbupnum;//点评点赞数目

    private List<Long> thumbuplist = new ArrayList<>();//点赞用户

    @Field(type = FieldType.Keyword)
    private String imgUrls;//点评图片

    private String[] pictures;//图片引用数组

    private int rank = 0; //总体评价星星

}